//api文件夹用于存放对后台请求的代码
import service from "@/api/index.js";

const categoryApi = {
    insert(category) {
        return service.post("/category", category);
    },
    delete(id) {
        return service.delete(`/category/${id}`);
    },
    update(category) {
        return service.put("/category", category);
    },
    //分页搜索
    selectByPage(condition, pageNum, pageSize) {
        if (pageNum) {
            condition.pageNum = pageNum;
        }
        if (pageSize) {
            condition.pageSize = pageSize;
        }
        return service.get("/category/search", {
            params: condition
        });
    },
    //根据id查询
    selectById(id) {
        return service.get(`/category/${id}`);
    },
    //获取所有父类
    selectAllParent() {
        return service.get("/category/allParent");
    },
}
export default categoryApi;//导出
